]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dnd: Emit drag-end in after snapback complete
authorColin Walters <walters@verbum.org>
Thu, 23 Jul 2009 21:34:01 +0000 (17:34 -0400)
committerColin Walters <walters@verbum.org>
Fri, 7 Aug 2009 17:29:34 +0000 (13:29 -0400)
Emit the signal at the correct time to take action
on snapback (i.e. after the end of the snapback animation).

Add a boolean to the drag-end signal saying whether it was accepted,
which ensures consumers know whether the drag was successful.

js/ui/dnd.js

index 300aeed7dba5bead6e049cca0222624b9f70ac9e..c7f753e48851d1ae36c5074fe885a295c573d9b5 100644 (file)
@@ -153,8 +153,6 @@ _Draggable.prototype = {
         if (!dragging)
             return false;
 
-        this.emit('drag-end', event.get_time());
-
         // Find a drop target
         actor.hide();
         let [dropX, dropY] = event.get_coords();
@@ -173,6 +171,7 @@ _Draggable.prototype = {
                     if (actor.get_parent() == actor.get_stage())
                         actor.destroy();
 
+                    this.emit('drag-end', event.get_time(), true);
                     return true;
                 }
             }
@@ -196,18 +195,20 @@ _Draggable.prototype = {
                            transition: "easeOutQuad",
                            onComplete: this._onSnapBackComplete,
                            onCompleteScope: this,
-                           onCompleteParams: [actor]
+                           onCompleteParams: [actor, event.get_time()]
                          });
         return true;
     },
 
-    _onSnapBackComplete : function (dragActor) {
+    _onSnapBackComplete : function (dragActor, eventTime) {
         if (this._dragOrigParent) {
             dragActor.reparent(this._dragOrigParent);
             dragActor.set_scale(this._dragOrigScale, this._dragOrigScale);
             dragActor.set_position(this._dragOrigX, this._dragOrigY);
-        } else
+        } else {
             dragActor.destroy();
+        }
+        this.emit('drag-end', eventTime, false);
     }
 };